package com.glory.dgcpcpda.activity.check;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.activity.check.QC_TaskExecuteNextActivity;
import com.glory.dgcpcpda.activity.mfg.ToolBindActivity;
import com.glory.dgcpcpda.activity.mfg.WBWorkEndActivity;
import com.glory.dgcpcpda.base.BaseActivity;
import com.glory.dgcpcpda.base.Constant;
import com.glory.dgcpcpda.base.MyApp;
import com.glory.dgcpcpda.entity.AdrefListEntity;
import com.glory.dgcpcpda.entity.EqpInfoEntity;
import com.glory.dgcpcpda.entity.EquipMentEntity;
import com.glory.dgcpcpda.entity.LotInfoEntity;
import com.glory.dgcpcpda.entity.QCformEntity;
import com.glory.dgcpcpda.entity.response.BaseResponseBean;
import com.glory.dgcpcpda.utils.LotUtils;
import com.glory.dgcpcpda.utils.NetUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.model.Response;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_DialogEntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_EntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralFragmentDialog;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralPop;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DialogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_PopUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_Utils;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class QC_TaskExecuteActivity extends BaseActivity {


    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.tvBaseSubmit)
    TextView tvBaseSubmit;
    @BindView(R.id.llMain)
    LinearLayout llMain;
    @BindView(R.id.flType)
    FrameLayout flType;
    @BindView(R.id.ivType)
    ImageView ivType;
    @BindView(R.id.tvType)
    TextView tvType;
    @BindView(R.id.etEqpID)
    FreeUI_ClearEditText etEqpID;
    @BindView(R.id.tvQCformID)
    TextView tvQCformID;
    @BindView(R.id.tvStepDesc)
    TextView tvStepDesc;
    @BindView(R.id.tvCustomerCode)
    TextView tvCustomerCode;
    @BindView(R.id.tvMainmatType)
    TextView tvMainmatType;
    @BindView(R.id.tvCircuitName)
    TextView tvCircuitName;
    @BindView(R.id.tvTiming)
    TextView tvTiming;
    @BindView(R.id.flOpportunity)
    FrameLayout flOpportunity;
    @BindView(R.id.ivOpportunity)
    ImageView ivOpportunity;
    @BindView(R.id.etLotID)
    FreeUI_ClearEditText etLotID;
    @BindView(R.id.flEqpList)
    FrameLayout flEqpList;
    @BindView(R.id.ivEqpList)
    ImageView ivEqpList;
    @BindView(R.id.etEqpIDList)
    FreeUI_ClearEditText etEqpIDList;
    @BindView(R.id.llEqpId)
    LinearLayout llEqpId;
    @BindView(R.id.llEqpIdList)
    LinearLayout llEqpIdList;
    @BindView(R.id.flLotList)
    FrameLayout flLotList;
    @BindView(R.id.ivLotList)
    ImageView ivLotList;
    @BindView(R.id.etLotList)
    FreeUI_ClearEditText etLotList;
    @BindView(R.id.llLot)
    LinearLayout llLot;
    @BindView(R.id.llLotIdList)
    LinearLayout llLotIdList;
    @BindView(R.id.etComments)
    FreeUI_ClearEditText etComments;
    @BindView(R.id.llComments)
    LinearLayout llComments;
    @BindView(R.id.etLocationId)
    FreeUI_ClearEditText etLocationId;
    @BindView(R.id.llOpportunity)
    LinearLayout llOpportunity;
    @BindView(R.id.tvEqpID)
    TextView tvEqpID;
    @BindView(R.id.tvLotID)
    TextView tvLotID;
    @BindView(R.id.tvLocationID)
    TextView tvLocationID;

    private FreeUI_GeneralPop mTypePop;
    private ArrayList<String> typeList = new ArrayList<>();
    private QCformEntity qCformEntity;
    private FreeUI_GeneralPop mOpportunityPop;
    private ArrayList<String> opportunityList = new ArrayList<>();
    private ArrayList<String> eqpIdList = new ArrayList<>();
    private ArrayList<String> lotIdList = new ArrayList<>();
    private static String message = "";
    private FreeUI_GeneralPop mEqpListPop;
    private FreeUI_GeneralPop mLotListPop;
    private LotInfoEntity lotInfoEntity;
    List<AdrefListEntity.Adref> adreflist= new ArrayList<>();
    private String timingCode="";

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_qc_taskexecute;
    }

    @Override
    protected void initView() {
        tvTitle.setText("QC首检巡检任务执行");
        setMainLayout(llMain);
        tvBaseSubmit.setText("下一步");

    }

    @Override
    protected void initData() {
        typeList.add("首检");
        typeList.add("巡检");

        getFirstIiming();
        /*if(adreflist!=null){
            for (AdrefListEntity.Adref entity : adreflist) {
                opportunityList.add(entity.getTEXT());
            }
        }*/

      /* opportunityList.add("交接班");
        opportunityList.add("换工单");
        opportunityList.add("设备维修");
        opportunityList.add("设备保养");
        opportunityList.add("换封装");
        opportunityList.add("换材料");
        opportunityList.add("换产品");
        opportunityList.add("重开机");
        opportunityList.add("X-RAY");
        opportunityList.add("塑封体二点偏心测量_巡检");
        opportunityList.add("塑封体二点偏心测量_换模具");
        opportunityList.add("塑封体二点偏心测量_修模具");
        opportunityList.add("塑封体三点偏心测量_巡检");
        opportunityList.add("塑封体三点偏心测量_换模具");
        opportunityList.add("塑封体三点偏心测量_修模具");
        opportunityList.add("塑封体错模测量巡检");
        opportunityList.add("塑封体错模测量换模具");
        opportunityList.add("塑封体错模测量修模具");
        opportunityList.add("修模具");
        opportunityList.add("换模具");*/


      /*  initEdit(etEqpID,s ->{
            qCformEntity = null;
            tvEqpID.setText(s);
            qcFormQuery(s,"EQP");
        });*/
    /*  initEdit(etLotID,s ->{
            qCformEntity = null;
            tvLotID.setText(s);
            qcFormQuery(s,"LOT");
        });*/

       /* initEdit(etLocationId,s ->{
            qCformEntity = null;
            tvLocationID.setText(s);
            qcFormQuery(s,"LOCATIONID");
        });*/

        initEdit(etEqpID,s ->{
            if(tvType.getText().toString().equals("首检")) {
                if(adreflist.size()>0){
                    for (AdrefListEntity.Adref entity : adreflist){
                        if(tvTiming.getText().toString().equals(entity.getTEXT())){
                            timingCode=entity.getKEY();
                            break;
                        }
                    }
                }
                // qCformEntity = null;
                if(timingCode.startsWith("CPD_Moding")||timingCode.startsWith("ChangeMolding_Mis_Pos")||
                        timingCode.startsWith("ChangeMolding_Piont")||timingCode.startsWith("CPD_Moding")||timingCode.startsWith("X-RAY")){

                }else{
                    clearEqpInfo();
                }
                tvEqpID.setText(s);
                searchEqpByLocation(s, "LOAD_STAGEID_BYEQPID");
            }else{
                qCformEntity = null;
                tvEqpID.setText(s);
                qcFormQuery(s,"EQP");
            }
        });
        initEdit(etLotID, s -> {
            //获取lot信息
          //  qCformEntity = null;
            if(tvType.getText().toString().equals("首检")) {
                clearEqpInfo();
                etEqpID.setText("");
                tvLotID.setText(s);
                searchLot(s);
            }else{
                qCformEntity = null;
                tvLotID.setText(s);
                qcFormQuery(s,"LOT");
            }
        });
        initEdit(etLocationId,s ->{
          //  qCformEntity = null;
            if(tvType.getText().toString().equals("首检")) {
                clearEqpInfo();
                tvLocationID.setText(s);
                searchEqpByLocation(s, "LOAD_STAGEID");
            }else{
                qCformEntity = null;
                tvLocationID.setText(s);
                qcFormQuery(s,"LOCATIONID");
            }
        });

        tvTiming.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                qCformEntity = null;
                if(!editable.toString().equals("")){
                    if(!getText(etEqpID).equals("")){
                        qcFormQuery(getText(etEqpID),"EQP");
                    }
                    if(!getText(etLotID).equals("")){
                        qcFormQuery(getText(etLotID),"LOT");
                    }
                    if(!getText(etLocationId).equals("")){
                        qcFormQuery(getText(etLocationId),"LOCATIONID");
                    }
                }

            }
        });


    }

    private void qcFormQuery(String s, String type) {
        if (tvType.getText().toString().equals("")){
            showToast("请选择检验类型",false);
            return;
        }
        if (llOpportunity.getVisibility() == View.VISIBLE){
            if (tvTiming.getText().toString().equals("")){
                showToast("请选择检验时机",false);
                return;
            }
        }
        FreeUI_EntityCallBack<BaseResponseBean<QCformEntity>> callBack = new FreeUI_DialogEntityCallBack<BaseResponseBean<QCformEntity>>
                (new TypeToken<BaseResponseBean<QCformEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess(Response<BaseResponseBean<QCformEntity>> response) {
                super.onSuccess(response);
                if (response.body().isSuccess(getApplicationContext(), true, getSupportFragmentManager())) {
                    qCformEntity = response.body().getResponse().getBody();
                    if (qCformEntity.getLOCATIONLIST().size() > 0) {
                        tvLocationID.setText(qCformEntity.getLOCATIONLIST().get(0));
                    }
                    if (qCformEntity.getLOTLIST().size() > 0) {
                        tvLotID.setText(qCformEntity.getLOTLIST().get(0));
                    }
                    if (qCformEntity.getEQUIPMENTLIST().size() > 0) {
                        tvEqpID.setText(qCformEntity.getEQUIPMENTLIST().get(0));
                    }
                    if (qCformEntity.getQCFORM() == null){
                        String mesage = type.equals("LOT")?"批次号":"设备号";
                        String mesage1 = type.equals("LOT")?"设备号":"批次号";
                        FreeUI_GeneralFragmentDialog tipDialog = FreeApi_DialogUtils.getConfirmDialog(MyApp.app, "确定", "请点击下一步开始巡检/首检！", () -> {
                            llEqpIdList.setVisibility(View.GONE);
                            llLotIdList.setVisibility(View.GONE);
                        });
                        tipDialog.show(getSupportFragmentManager(),"DIALOG");
                    }else {
                        tvLotID.setText(qCformEntity.getQCFORM().getLOTID());
                        tvEqpID.setText(qCformEntity.getQCFORM().getEQUIPMENTID());
                        tvQCformID.setText(qCformEntity.getQCFORM().getQCFORMID());
                        tvStepDesc.setText(qCformEntity.getQCFORM().getSTEPDESC());
                        tvCustomerCode.setText(qCformEntity.getQCFORM().getCUSTOMERCODE());
                        tvMainmatType.setText(qCformEntity.getQCFORM().getMAINMATTYPE());
                        tvCircuitName.setText(qCformEntity.getQCFORM().getCIRCUITNAME());
                    }
                }
            }

            @Override
            public void onError(Response<BaseResponseBean<QCformEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "QCFORMQUERY");
            }
        };
        JsonObject map = new JsonObject();
        switch (type){
            case "EQP":
                map.addProperty("EQUIPMENTID", s);
                break;
            case "LOT":
                map.addProperty("LOTID", s);
                break;
            case "LOCATIONID":
                map.addProperty("LOCATIONID", s);
                break;
        }
        String INSPECTTYPE = "";
        switch (tvType.getText().toString()){
            case "首检":
                INSPECTTYPE = "First";
                break;
            case "巡检":
                INSPECTTYPE = "Patrol";
                break;
        }
        String INSPECTTIMING = "";
        if(adreflist.size()>0){
            for (AdrefListEntity.Adref entity : adreflist){
                if(tvTiming.getText().toString().equals(entity.getTEXT())){
                    INSPECTTIMING=entity.getKEY();
                    break;
                }
            }
        }

        if (llOpportunity.getVisibility() != View.VISIBLE){
            INSPECTTIMING = "";
        }
        map.addProperty("INSPECTTYPE", INSPECTTYPE);
        map.addProperty("INSPECTTIMING", INSPECTTIMING);
        NetUtils.requestPostNet("CPC.QCFORMQUERY", "TRANSFERMES", this, map, callBack);
    }

    @OnClick({R.id.tvBaseSubmit,R.id.flType,R.id.flOpportunity,R.id.ivEqpList,R.id.ivLotList})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tvBaseSubmit:
                etEqpID.requestFocus();
                if (qCformEntity == null){
                    showToast("请完成扫描操作",false);
                    return;
                }
                if (qCformEntity.getQCFORM() == null){
                    if (tvEqpID.getText().toString().equals("")){
                        showToast("设备号不能为空",false);
                        return;
                    }
                    createQCid();
                }else {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("DATA", qCformEntity);
                    bundle.putString("INSPECTTIMING",tvTiming.getText().toString());
                    bundle.putString("TYPE",tvType.getText().toString());
                    bundle.putString("LocationId",etLocationId.getText().toString());
                    FreeApi_Utils.skipWithExtraIntent("", bundle, QC_TaskExecuteActivity.this, QC_TaskExecuteNextActivity.class);
                    deleteViewData();
                }
                break;
            case R.id.flType:
                if (mTypePop != null) {
                    if (mTypePop.isShowing()) {
                        mTypePop.dismiss();
                    }
                } else {
                    mTypePop = FreeApi_PopUtils.getNormalPop(getApplicationContext(), flType.getWidth(), typeList, ivType, (codeS, i) -> {
                        tvType.setText(codeS);
                        if (codeS.equals("巡检")){
                            llOpportunity.setVisibility(View.GONE);
                        }else {
                            llOpportunity.setVisibility(View.VISIBLE);
                        }
                    });
                }
                FreeApi_PopUtils.setArrowShow(ivType);
                mTypePop.showAsDropDown(flType, 0, 0);
                break;
            case R.id.flOpportunity:
                if (mOpportunityPop != null) {
                    if (mOpportunityPop.isShowing()) {
                        mOpportunityPop.dismiss();
                    }
                } else {
                    mOpportunityPop = FreeApi_PopUtils.getNormalPop(getApplicationContext(), flOpportunity.getWidth(), opportunityList, ivOpportunity, (codeS, i) -> {
                        tvTiming.setText(codeS);
                    });
                }
                FreeApi_PopUtils.setArrowShow(ivOpportunity);
                mOpportunityPop.showAsDropDown(flOpportunity, 0, 0);
                break;
            case R.id.ivEqpList:
                if (mEqpListPop != null) {
                    if (mEqpListPop.isShowing()) {
                        mEqpListPop.dismiss();
                    }
                } else {
                    mEqpListPop = FreeApi_PopUtils.getNormalPop(getApplicationContext(), flEqpList.getWidth(), eqpIdList, ivEqpList, (codeS, i) -> {
                        etEqpIDList.setText(codeS);
                        tvEqpID.setText(codeS);
                    });
                }
                FreeApi_PopUtils.setArrowShow(ivEqpList);
                mEqpListPop.showAsDropDown(flEqpList, 0, 0);
                break;
            case R.id.ivLotList:
                if (mLotListPop != null) {
                    if (mLotListPop.isShowing()) {
                        mLotListPop.dismiss();
                    }
                } else {
                    mLotListPop = FreeApi_PopUtils.getNormalPop(getApplicationContext(), flLotList.getWidth(), lotIdList, ivLotList, (codeS, i) -> {
                        etLotList.setText(codeS);
                        tvLotID.setText(codeS);
                    });
                }
                FreeApi_PopUtils.setArrowShow(ivLotList);
                mLotListPop.showAsDropDown(flLotList, 0, 0);
                break;
        }
    }

    private void createQCid() {
        FreeUI_EntityCallBack<BaseResponseBean<QCformEntity>> callBack = new FreeUI_DialogEntityCallBack<BaseResponseBean<QCformEntity>>
                (new TypeToken<BaseResponseBean<QCformEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess(Response<BaseResponseBean<QCformEntity>> response) {
                super.onSuccess(response);
                if (response.body().isSuccess(getApplicationContext(), false, getSupportFragmentManager())) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("DATA",response.body().getResponse().getBody());
                    bundle.putString("INSPECTTIMING",tvTiming.getText().toString());
                    bundle.putString("TYPE",tvType.getText().toString());
                    bundle.putString("LocationId",etLocationId.getText().toString());
                    FreeApi_Utils.skipWithExtraIntent("",bundle,QC_TaskExecuteActivity.this, QC_TaskExecuteNextActivity.class);
                    deleteViewData();
                }
            }

            @Override
            public void onError(Response<BaseResponseBean<QCformEntity>> response) {
                super.onError(response);
                loadError(response.getException(),"QCFORMCREATE");
            }
        };
        QCformEntity qCformEntity = new QCformEntity();
        qCformEntity.setEQUIPMENTID(tvEqpID.getText().toString());
        qCformEntity.setLOTID(tvLotID.getText().toString());
        qCformEntity.setLOCATIONID(tvLocationID.getText().toString());
        String INSPECTTYPE = "";
        switch (tvType.getText().toString()){
            case "首检":
                INSPECTTYPE = "First";
                break;
            case "巡检":
                INSPECTTYPE = "Patrol";
                break;
        }
        String INSPECTTIMING = "";
        if(adreflist.size()>0){
            for (AdrefListEntity.Adref entity : adreflist){
                if(tvTiming.getText().toString().equals(entity.getTEXT())){
                    INSPECTTIMING=entity.getKEY();
                    break;
                }
            }
        }

        if (llOpportunity.getVisibility() != View.VISIBLE){
            INSPECTTIMING = "";
        }
        qCformEntity.setINSPECTSTEPNAME(tvStepDesc.getText().toString());
        qCformEntity.setINSPECTTIMING(INSPECTTIMING);
        qCformEntity.setINSPECTTYPE(INSPECTTYPE);
        qCformEntity.setABANDONINGREASON(getText(etComments));

        JsonObject map = new JsonObject();
        map.add("QCFORM", new JsonParser().parse(new Gson().toJson(qCformEntity)).getAsJsonObject());
        NetUtils.requestPostNet("CPC.QCFORMCREATE", "TRANSFERMES", this, map, callBack);
    }

    public static void setMessage(String s) {
        message = s;
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (message.equals("1")){
            etEqpID.setText("");
            tvQCformID.setText("");
            tvStepDesc.setText("");
            tvCustomerCode.setText("");
            tvMainmatType.setText("");
            tvCircuitName.setText("");
            message = "";
        }
    }

    void deleteViewData(){
        etEqpID.setText("");
        etLocationId.setText("");
        etLotID.setText("");
        tvEqpID.setText("");
        tvLotID.setText("");
        tvLocationID.setText("");
        tvQCformID.setText("");
        tvStepDesc.setText("");
        tvCustomerCode.setText("");
        tvMainmatType.setText("");
        tvCircuitName.setText("");
        tvTiming.setText("");
    }
    void clearEqpInfo(){
        tvEqpID.setText("");
        tvLocationID.setText("");
        tvLotID.setText("");
        tvTiming.setText("");
    }
    private void getFirstIiming() {
        FreeUI_EntityCallBack<BaseResponseBean<AdrefListEntity>> callBack = new FreeUI_DialogEntityCallBack<BaseResponseBean<AdrefListEntity>>
                (new TypeToken<BaseResponseBean<AdrefListEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess(Response<BaseResponseBean<AdrefListEntity>> response) {
                super.onSuccess(response);
                if (response.body().isSuccess(getApplicationContext(),true,getSupportFragmentManager())){
                    // adreflist = response.body().getResponse().getBody().getADREFLIST();

                   for (AdrefListEntity.Adref entity : response.body().getResponse().getBody().getADREFLIST()) {
                       // StepNameList1.add(entity.getKEY());
                     // opportunityList.add(entity.getTEXT());
                       adreflist.add(entity);
                    }
                }
            }

            @Override
            public void onError(Response<BaseResponseBean<AdrefListEntity>> response) {
                super.onError(response);
                loadError(response.getException(),"ADREFLISTQUERY");

            }
        };
        JsonObject map = new JsonObject();
        map.addProperty("REFERENCETYPE","USER");
        map.addProperty("REFERENCENAME","CPC_QC_INSPECT_TIMING");
        NetUtils.requestPostNet("CPC.ADREFLISTQUERY","ADREFLISTQUERY",this,map,callBack);
    }

    private void searchLot(String s) {
        opportunityList.clear();
        mOpportunityPop=null;
        LotUtils.searchLotInfo(QC_TaskExecuteActivity.this, s, getSupportFragmentManager(), new LotUtils.netCallback<LotInfoEntity>() {
            @Override
            public void onSuccess(LotInfoEntity response) {
                lotInfoEntity = response;
                String state = response.getLOT().getSTATE();
                String stageId=response.getSTAGEID();
                if(adreflist!=null){
                    for (AdrefListEntity.Adref entity : adreflist){
                        if(stageId!=null&&!stageId.equals("")){
                            if(entity.getDESCRIPTION().contains(stageId)){
                                opportunityList.add(entity.getTEXT());
                            }
                        }else{
                            opportunityList.add(entity.getTEXT());
                        }
                    }
                }
            }

            @Override
            public void onFail(Throwable t) {
                loadError(t, "LOTQUERY");
                showConfirmDialog(QC_TaskExecuteActivity.this,"接口不通");
            }
        });
    }

    private void searchEqpByLocation(String s,String actionType){
        opportunityList.clear();
        mOpportunityPop=null;
        FreeUI_EntityCallBack<BaseResponseBean<EqpInfoEntity>> callBack = new FreeUI_DialogEntityCallBack<BaseResponseBean<EqpInfoEntity>>
                (new TypeToken<BaseResponseBean<EqpInfoEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess(Response<BaseResponseBean<EqpInfoEntity>> response) {
                super.onSuccess(response);
                if (response.body().isSuccess(getApplicationContext(),false,getSupportFragmentManager())){
                    EqpInfoEntity body = response.body().getResponse().getBody();
                    String stageId= body.getSTAGEID();
                    tvEqpID.setText(body.getEQUIPMENT().getEQUIPMENTID());
                    tvLocationID.setText(body.getEQUIPMENT().getLOCATION());
                    if(tvType.getText().toString().equals("首检")){
                        if(stageId!=null&&!stageId.equals("none")){
                            for (AdrefListEntity.Adref entity : adreflist) {
                                if (entity.getDESCRIPTION().contains(stageId)) {
                                    opportunityList.add(entity.getTEXT());
                                }
                            }
                        }/*else{
                            showToast("该设备没有批次进站作业!",false);
                        }*/

                    }

                }
            }

            @Override
            public void onError(Response<BaseResponseBean<EqpInfoEntity>> response) {
                super.onError(response);
                loadError(response.getException(),"TRANSFERMES");

            }
        };
        JsonObject map = new JsonObject();
        EquipMentEntity equipMentEntity = new EquipMentEntity();
        equipMentEntity.setEQUIPMENTID(s);
        map.add("EQUIPMENT",new JsonParser().parse(new Gson().toJson(equipMentEntity)).getAsJsonObject());
        map.addProperty("ACTIONTYPE",actionType);
        NetUtils.requestPostNet("CPC.EQPQUERY","TRANSFERMES",this,map,callBack);
    }
}
